package com.booter.ws.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class WebSocketController {

//    @Autowired
//    private WebSocketTransferService transferService;


    /***
     * 后端向前端广播
     * @MessageMapping注解，功能类似@RequestMapping，它是存在于Controller中的，定义一个消息的基本请求，功能也跟@RequestMapping类似，包括支持通配符``的url定义等等
     * @SendTo定义了消息的目的地。接收/topic/ws/broadcast发来的value，然后将value转发到/topic/notice客户端
     * @return
     */
    //@MessageMapping("/sendChatMsgById/{accountId}")//点对点消息
    @MessageMapping("/message/replay")
    @SendTo("/topic/ws/broadcast")
    public Object broadcast() {
        return "ok";
    }

    /***
     * 三、回执 ws.send
     * @param param
     * @param token
     * @return
     */
//    @MessageMapping("/message/receipt")
//    public JsonResultVo broadcast(Map<String, String> param, @Header("Authorization") String token) {
//        String msgId = param.get("messageId");
//        String traceId = param.get("traceId");
//        String type = param.get("messageType");
//        String user = JwtUtil.getClaim(token, Constants.ACCOUNT);
//        transferService.ack(user, msgId, Long.parseLong(traceId), type);
//        return JsonResultVo.success();
//    }


}